<template>
  <div class="page">
    <!-- tab1 -->
		<app-tab1></app-tab1>
    <!-- tab2 -->
    <van-tabs v-model="tab2" class="tab2" @click="tabClick">
      <van-tab title="岗位认证"></van-tab>
      <van-tab title="线上考试"></van-tab>
      <van-tab title="线下培训"></van-tab>
    </van-tabs>
    <!-- 父认证 -->
    <div class="list_box" v-if="tab2==0">
          <router-link v-for="(item,index) in list0" :key="index" to="/list3_1" class="list_item">
            <div class="titBox">
              <div class="tit">{{item.title}}</div>
              <span class="listLabel listLabel_3" v-if="item.status=='未通过'">{{item.status}}</span>
              <span class="listLabel listLabel_1" v-if="item.status=='通过'">{{item.status}}</span>
            </div>
            <p>{{item.created_at}}</p>
        </router-link>
    </div>
    <!-- 子认证 -->
    <!-- <div class="list_box" v-if="tab2==1">
        <div v-for="(item,index) in list1" :key="index" class="list_item list_item1">
            <div class="titBox">
              <div class="tit">{{item.name}}</div>
              <span class="listLabel listLabel_3" v-if="item.status=='未通过'">{{item.status}}</span>
              <span class="listLabel listLabel_1" v-if="item.status=='通过'">{{item.status}}</span>
            </div>
            <p>{{item.type}}</p>
            <p>{{item.created_at}}</p>
        </div>
    </div> -->
    <!-- 在线考试 -->
    <div class="list_box" v-if="tab2==1">
      <div v-for="(item,index) in list1" :key="index" class="list_item list_item1">
            <div class="titBox">
              <div class="tit">{{item.title}}</div>
              <!-- <span class="listLabelText listLabelText_3" style="top:12px;">{{item.score}}分</span> -->
              <span class="listLabel listLabel_3" style="top:28px">{{item.test_status}}</span>
            </div>
            <p>{{item.updated_at}}</p>
        </div>
    </div>
    <!-- 在线学习
    <div class="list_box" v-if="tab2==2">
      <div v-for="(item,index) in list2" :key="index" class="list_item">
            <div class="titBox">
              <div class="tit">{{item.title}}</div>
            <span class="listLabel listLabel_3">{{item.learn_status}}</span>
            </div>
            <p>{{item.updated_at}} <span class="time_1">{{item.duration}}</span></p>
        </div>
    </div> -->
    <!-- 培训班 -->
    <div class="list_box" v-if="tab2==2">
      <div v-for="(item,index) in list2" :key="index" class="list_item">
            <div class="titBox titBox1">
           <div class="tit">{{item.attences}}</div>
         </div>
         <div class="titBox titBox2">
           <div class="tit">{{item.title}}</div>
           <span class="listLabelText listLabelText_3" style="bottom:0px;">{{item.score}}分</span>
            <span class="listLabel listLabel_1" v-if="item.enroll_status=='已报名'">{{item.enroll_status}}</span>
            <span class="listLabel listLabel_2" v-if="item.enroll_status=='请假'">{{item.enroll_status}}</span>
            <span class="listLabel listLabel_3" v-if="item.enroll_status=='未报名'">{{item.enroll_status}}</span>
         </div>
         <p>{{item.start}} - {{item.end}}</p>
        </div>
    </div>
  </div>
</template>

<script>
import { Dialog } from "vant";
import tab1 from '@/components/common/tab1';
export default {
  data() {
    return {
      tab2:0,
      list0: [],
      list1: [],
      list2: [],
      loading: false,
      finished: false
    };
  },
  mounted: function() {
    this.getList0()
    maxusJSB.tojson({title:"培训中心",left:"关闭"})
    
  },
		components:{
			"app-tab1":tab1
		},
  methods: {
    // 父认证
    getList0() {
      this.$http
        .get("?key=&request=front&operation=record-cert&client=1&by=admin&user_id="+this.getUserID+"&_="+Date.parse(new Date()))
        .then(response => {
          if(response.ret==1){
            this.list0=response.data
          }
        });
    },
    // 子认证
    // getList1() {
    //   this.$http
    //     .get("?key=&request=front&operation=record-cert-list&client=1&by=admin&user_id="+this.getUserID+"&_="+Date.parse(new Date()))
    //     .then(response => {
    //       if(response!=null){
    //         this.list1=response
    //       }
    //     });
    // },
    // 在线考试
    getList1() {
      this.$http
        .get("?key=&request=front&operation=record-exam&client=1&by=admin&user_id="+this.getUserID+"&_="+Date.parse(new Date()))
        .then(response => {
          if(response.ret==1){
            this.list1=response.data
          }
        });
    },
    // 在线学习
    // getList2() {
    //   this.$http
    //     .get("?key=&request=front&operation=record-learning&client=1&by=admin&user_id="+this.getUserID+"&_="+Date.parse(new Date()))
    //     .then(response => {
    //       if(response!=null){
    //         this.list2=response
    //       }
    //     });
    // },
    // 在线培训
    getList2() {
      this.$http
        .get("?key=&request=front&operation=record-class&client=1&by=admin&user_id="+this.getUserID+"&_="+Date.parse(new Date()))
        .then(response => {
          if(response.ret==1){
            this.list3=response.data
          }
        });
    },
    // 切换TAB
    tabClick(index, title){
      switch (index) {
        case 0:
          this.getList0()
        break;
        case 1:
          this.getList1()
        break;
        case 2:
          this.getList2()
        break;
      }
        
    }
  }
};
// 统计
    (function(g, d, s, t) {
		g['_cts'] = g['_cts'] || {};
		g['_cts'][t] = g['_cts'][t] || {};
		g[t] = g[t] || function() {
			(g[t].c = g[t].c || []).push(arguments);
		}
		var c = d.createElement(s),
			h = d.getElementsByTagName(s)[0];
		c.src = '//c.saicmaxus.com/dmp/t.js';
		h.parentNode.insertBefore(c, h);
	})(window, document, 'script', 'pilot');

	pilot('set', 'siteId', 'CCS82280');
	pilot('set', 'accountId', 'pilot');
	pilot('set', 'baseUrl', 'https://trk.maxuscloud.com/');
	pilot('track', 'pageview','index3');
</script>